package com.oocl.command;

public class CommandResolver {
	private static String[] cmds = {"scp","ls","rm"};
   
	 public static  Command resoleCommand(String commandStr){
		 Command cmd = null;
		 String[] strs = commandStr.split(" ");
		 if(contain(strs[0])){
			 cmd = new Command();
			 cmd.setKey(strs[0]);
			 cmd.setOperationType(strs[0]);
			 if(strs.length ==2){
				 cmd.setValues(new String[]{strs[1]});
			 }else if(strs.length ==3){
				 cmd.setValues(new String[]{strs[1],strs[2]});
			 }
		 }
		 return cmd;
	 }
	 
	 
	 private static boolean contain(String s){
		 boolean result =false;
		 for(int i=0;i<cmds.length;i++){
			 if(s.equals(cmds[i])){
				 result = true;
				 break;
			 }
		 }
		 return result;
	 }
	
}
